* Set the working directory to the main one of the project

clear

import delimited using "model\results_model\cf_for_stata.csv", clear

rename v1 cz
rename v2 decade
rename v3 mod_popgr_throut_noa
rename v4 mod_popgr_throut_noa_intra
rename v5 mod_popgr_throut_noa_nomigr

merge 1:1 cz decade using dsets\cz_data\dataset_reduced_form_cpp.dta

xtset cz decade, delta(20)

*** Table 3
* column 1:
reghdfe pop_growth exposure log_lagged_population log_lagged_population_2 l.log_totpat_cz_decade l.hc_summary_ranking local_industry_shock if decade >= 1910 [weight = lagged_pop_share], absorb(decade_division_id) cluster(cz decade_division_id)
* column 2:
reghdfe mod_popgr_throut_noa exposure log_lagged_population log_lagged_population_2 l.log_totpat_cz_decade l.hc_summary_ranking local_industry_shock if decade >= 1910 [weight = lagged_pop_share], absorb(decade_division_id) cluster(cz decade_division_id)
* column 3:
reghdfe mod_popgr_throut_noa_intra exposure log_lagged_population log_lagged_population_2 l.log_totpat_cz_decade l.hc_summary_ranking local_industry_shock if decade >= 1910 [weight = lagged_pop_share], absorb(decade_division_id) cluster(cz decade_division_id)

*** Specialization vs Diversification:

clear

import delimited using "model\results_model\spec_sim_for_stata_onebgp.csv", clear

gen decade = 2010
rename v1 cz 
rename v2 data_spec
rename v3 model_spec
rename v4 model_spec_adj
rename v5 sd_full
rename v6 sd_intra
rename v7 pop

merge 1:1 cz decade using dsets\cz_data\dataset_reduced_form_cpp.dta, keep(match) nogen

gen log_pop = ln(pop)

*** Appendix Table A.4
* column 1:
reg sd_full i.division log_pop model_spec_adj [weight = pop]
* column 1:
reg sd_intra i.division log_pop model_spec_adj [weight = pop]

sum sd_full sd_intra [weight = pop]

sum model_spec_adj [weight = pop], d
* Boston: .0076626
* Austin: .062239
display (.062239-.0076626)*.8405588
* .04587467
